<template>
  <div class="search-panel">
    <el-row class="m-header-searchbar">
      <el-col class="left" :span="3">
        <img src="//s0.meituan.net/bs/fe-web-meituan/e5eeaef/img/logo.png" alt="美团">
      </el-col>
      <el-col class="center" :span="15">
        <div class="wrapper">
          <el-input 
            v-model="search" 
            placeholder="搜索商家或地点"
            @focus="handleFocus"
            @blur="handleBlur"
            @input="handleInput"
          ></el-input>
          <dl class="hot-search" v-if="isHotSearch">
            <dt>热门搜索</dt>
            <dd v-for="(item, index) in hotSearch" :key="index">
              {{ item }}
            </dd>
          </dl>
          <dl class="search-list" v-if="isSearchList">
            <dd v-for="(item, index) in searchList" :key="index">
              {{ item }}
            </dd>
          </dl>
          <el-button class="el-button el-button--primary">
            <i class="el-icon-search"></i>
          </el-button>
        </div>
        <p class="suggest">
          <a href="#">故宫博物馆</a>
          <a href="#">故宫博物馆</a>
          <a href="#">故宫博物馆</a>
          <a href="#">故宫博物馆</a>
        </p>
        <ul class="nav">
          <li>
            <nuxt-link to="" class="takeout">美团外卖</nuxt-link>
          </li>
          <li>
            <nuxt-link to="" class="movie">猫眼电影</nuxt-link>
          </li>
          <li>
            <nuxt-link to="" class="hotel">美团酒店</nuxt-link>
          </li>
          <li>
            <nuxt-link to="" class="apartment">民宿/公寓</nuxt-link>
          </li>
          <li>
            <nuxt-link to="" class="business">商家入驻</nuxt-link>
          </li>
        </ul>
      </el-col>
      <el-col class="right" :span="6"></el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data () {
    return {
      search: '',
      isFocus: false,
      hotSearch: ['欢乐谷', '火锅'],
      searchList: ['火锅', '电影']
    }
  },
  computed: {
    isHotSearch () {
      return this.isFocus && !this.search;
    },
    isSearchList () {
      return this.isFocus && this.search;
    }
  },
  methods: {
    handleFocus () {
      this.isFocus = true;
    },
    handleBlur () {
      setTimeout(() => {
        this.isFocus = false;
      }, 200);
    },
    handleInput () {

    }
  }
}
</script>

